<?php
/**
 * Created by PhpStorm.
 * User: 胡诚
 * Date: 2018/11/9
 * Time: 16:18
 */

namespace App\Controllers;

use App\Services\HallSettingService;
use Illuminate\Http\Request;


class HallSettingController extends BaseController
{
//    public $allows = ['hallUpdateStatus', 'getHallname', 'updateHallPassword', 'getSmsPlatform', 'updateSms'];

    /**
     * 修改厅主状态
     * @param Request $request
     * @return mixed
     * @throws \App\Exceptions\CustomException
     * @throws \Illuminate\Validation\ValidationException
     */
    public function hallUpdateStatus(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required|integer',
            'hall_status'  => 'required|integer',
        ]);
        $value = $request->input();
        return HallSettingService::updateStaus($value);
    }

    /**
     * 修改厅主密码
     * @param Request $request
     * @return mixed
     * @throws \App\Exceptions\CustomException
     * @throws \Illuminate\Validation\ValidationException
     */
    public function updateHallPassword(Request $request)
    {
        $this->validate($request, [
            'hall_id'      => 'required|integer',
            'password_one' => 'required',
            'password_two' => 'required',
        ]);
        $value = $request->input();
        return HallSettingService::updatePassword($value);
    }

    /**
     * 获取短信数据
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function getSmsPlatform(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required|integer'
        ]);
        $hallId = $request->input('hall_id');
        return HallSettingService::getSmsPlatform($hallId);
    }

    /**
     * 修改短信数据
     * @param Request $request
     * @return mixed
     * @throws \App\Exceptions\CustomException
     * @throws \Illuminate\Validation\ValidationException
     */
    public function updateSms(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required|integer',
            'sms_id'  => 'required|integer',
            'config'  => 'required',
        ]);
        $hallId = $request->input();
        return HallSettingService::updateSms($hallId);
    }

    /**
     * 谷歌验证用户列表
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function googleList(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required|integer',
        ]);
        $hallId = $request->input('hall_id');
        return HallSettingService::googleList($hallId);
    }

    /**
     * 修改Google验证绑定状态
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function updateGoogleStatus(Request $request)
    {
        $this->validate($request, [
            'user_id' => 'required|integer',
        ]);
        $values = $request->input();
        return HallSettingService::updateGoogleStatus($values);
    }
}